// 文件上传
jQuery(function() {


	var MbsUpload = function(element, option) {
		var that = this;
		this.$element = $(element);
		this.option = option;
        this.DIALOG_CLASS="upload-dialog";
        this.uploadStatus = 'done';
        this.nameCache = {};
        this.hasPreview = false;

		this.getAttachmentsByBoxId = that.option.basePath + '/new/fileresource/getAttachmentsByBoxId.json';
        this.getAttachmentsByBoxMetadata = that.option.basePath + '/new/fileresource/getAttachmentsByBoxMetadata.json';
        
        this.download = that.option.basePath + '/new/fileresource/download';
        
		this.up = that.option.basePath + '/new/fileresource/serialnumber/up.json';
        this.down = that.option.basePath + '/new/fileresource/serialnumber/down.json';
        
        this.uploadByBoxId = that.option.basePath + '/new/fileresource/uploadByBoxId.json';
        this.uploadByBoxMetadata = that.option.basePath + '/new/fileresource/uploadByBoxMetadata.json';
        
        this.deleteBoxByMetadata = that.option.basePath + '/new/fileresource/deleteBoxByMetadata.json';
		this.deleteAttachment = that.option.basePath + '/new/fileresource/deleteAttachment.json';
		this.deleteBoxByBoxId = that.option.basePath + '/new/fileresource/deleteBoxByBoxId.json';
		this.preview = that.option.basePath + '/new/fileresource/preview.json';
		this.previewDelete = that.option.basePath + '/new/fileresource/deletePreviewTempFile.json';
		
		this.queryAuth = that.option.basePath + '/new/fileresource/getWeb2PreviewAuth.json';
		
		this.getUserId = that.option.basePath + '/new/fileresource/getUser.json';
		
		this.uploadByStoreAddress =  that.option.basePath + '/new/fileresource/uploadByStoreAddress.json';
		
		this.swfPath = that.option.basePath + '/static/ui-frame/webuploader/0.1.5/Uploader.swf';

		this.exaimArgs();
		
		
		var that = this;
		this.hasPreviewAuth().done(function(res){
			that.hasPreview = res;
			that.loadTable(that);
		});
		
    }         
	
	/**
	 * 只接受如下几种参数，形式：|如果有boxId则其他都不用验证，如果没有
	 *  5.	系统id，模块id，文种id，流程实例id；
	 *	6.	系统id，模块id，文种id；
	 *	7.	系统id，模块id；
	 *	8.	系统id。
     *
	 */
        MbsUpload.prototype.exaimArgs = function(){
            this.$table = this.$element
            this.$title= null == (this.option.title ||''==this.option.title)?"上传附件":this.option.title
            this.$isreadonly = this.option.isReadonly
            
            if(null == this.$isreadonly){
                throw new Error('请指定加载的附件列表是否为只读的.为表格加上[data-is-readonly=true]则是只读表格,false则不是')
            }
            this.$systemid = this.option.systemId
            this.$modelid = this.option.modelId
            this.$bodefinedid = this.option.bodefinedId
            this.$instanceid = this.option.instanceId

            this.$boxid = this.option.boxId
            this.$groupcode = this.option.groupCode
            this.$category = this.option.category
            
            if(null == this.$boxid||'' == this.$boxid){

                if(null == this.$systemid||'' == this.$systemid){
                	throw new Error('请至少配置systemId.为表格加上[data-system-id="mbs"]则为系统mbs下的附件')
                }else{

                    if(null != this.$groupcode && ''!=this.$groupcode){

                        if(null == this.$instanceid||'' == this.$instanceid||null == this.$modelid||'' == this.$modelid||'' == this.$bodefinedid||'' == this.$bodefinedid){
                        	throw new Error('已配置了组编号,请配置系统id.模块id.文种id.流程实例id.例[data-system-id="mbs"  data-model-id="shphy" data-bodefined-id="1111"  data-instance-id="11" ]')
                        }
                    }
                    if(null != this.$instanceid && ''!=this.$instanceid){

                        if(null == this.$modelid||'' == this.$modelid||'' == this.$bodefinedid||'' == this.$bodefinedid){
                        	throw new Error('已配置了实例id,请配置系统id.模块id.文种id.例[data-system-id="mbs"  data-model-id="shphy" data-bodefined-id="1111" ]')
                        }
                    }
                    if(null != this.$bodefinedid && ''!=this.$bodefinedid){

                        if(null == this.$modelid||'' == this.$modelid){
                        	throw new Error('已配置了文种id,请配置系统id.模块id.例[data-system-id="mbs"  data-model-id="shphy"  ]')
                        }
                    }
                }
                this.selectPath = this.getAttachmentsByBoxMetadata;
                this.uploadPath = this.uploadByBoxMetadata;
            }else{
            	this.selectPath = this.getAttachmentsByBoxId;
                this.uploadPath = this.uploadByBoxId;
            }
            this.deletePath = this.deleteAttachment;
            this.downloadPath = this.download;
            this.moveupPath = this.up;
            this.movedownPath = this.down;
            this.previewPath = this.preview;
            this.previewDeletePath = this.previewDelete;
          
        }
        MbsUpload.prototype.loadTable = function(that){
        	
            if(that.option.isReadonly){
            	
            	that.loadReadonlyTable();
            }else{
            	if(null != that.option.category && '' != that.option.category){
            		that.loadOTWidthCategory();
            	}else{
            		that.loadOperateTable();
            	}
            }
        }
        MbsUpload.prototype.loadReadonlyTable = function(){
        	
            var that = this;
         
            $.ajax({
            type : "get",
            url : that.selectPath,
            cache:false,
            dataType : "json",
            data :{
                systemId:this.$systemid,
                modelId:this.$modelid,
                boDefinedId:this.$bodefinedid,
                instanceId:this.$instanceid,
                boxId:this.$boxid,
                groupCode:this.$groupcode}
            }).done(function(reslist){
            	var attachSum = reslist.attachmentList.length;
            	if(attachSum >0){
            		if(that.hasPreview){
            			that.$table.html('<thead><tr><td class="text-right col-xs-1"><input type="checkbox" name="checkAll"></td><td colspan="2"  class="text-left col-xs-11"><button type="button" class="btn btn-sm tool-btn download-zip" >批量下载</button>&nbsp;&nbsp;<button type="button" class="btn btn-sm tool-btn download-web" >下载至网盘</button></td></tr></thead><tbody></tbody>')    
            		}else{
            			that.$table.html('<thead><tr><td class="text-right col-xs-1"><input type="checkbox" name="checkAll"></td><td colspan="2"  class="text-left col-xs-11"><button type="button" class="btn btn-sm tool-btn download-zip" >批量下载</button></td></tr></thead><tbody></tbody>')    
            		}
                    
            	}

                that.$table.find('tbody').first().html(that.getTableTrs(
                				{'columns':[{'data':'id','myclass':'text-right col-xs-1','formatFunction':function(val,row){
                                               return '<input type="checkbox" name="check" id="'+val+'">';
                                           }},
                                 {'data':'fileName','myclass':'text-left col-xs-6','formatFunction':function(val,row){
                                               return '<label  title="'+val+'" for="'+row.id+'">'+val+'</label>';
                                           }},
                                 {'data':'id','myclass':'text-right col-xs-5 operate','formatFunction':function(val,row){

                                	 var oHtml = '<div><a href="javascript:void(0);" data-id="'+val+'" class="download-a"><i class="fa fa-download icon-green"></i><font>下载</font></a>';
                                	 if(row.canbePreview && that.hasPreview){
                                		 oHtml = oHtml +'<a href="javascript:void(0);" data-id="'+val+'" class="preview-a"><i class="fa fa fa-eye icon-orange"></i><font>预览</font></a>';
                                	 }
                                	 oHtml = oHtml +'</div>';
                                	 return oHtml;
                                           }}]
                  },reslist.attachmentList));
                that.$table.data("attachSum",attachSum);
                
                if(attachSum >0){
                	
                	that.bingCheck(that);
	                
                	that.bingDownloadZip(that);

            		if(that.hasPreview){
            			that.bingDownloadWeb(that, reslist.attachmentList);
            		}
                 	
	                
                }
                
                that.bingDownloadA(that);
                
                if(that.hasPreview){
                    that.bingPreview(that);
        		}
                

            })
            .fail(function(r){
                BootstrapUDialog.alert({ title: '提醒', message: '初始化附件列表数据失败', closable: true,  draggable: true });
            });
        }
        
        MbsUpload.prototype.loadOTWidthCategory = function(){
        	
        	  var loadDtd = $.Deferred();
        	  
            var that = this;
                     
            $.ajax({
            type : "get",
            url : that.selectPath,
            cache:false,
            dataType : "json",
            data :  {
                systemId:that.$systemid,
                modelId:that.$modelid,
                boDefinedId:that.$bodefinedid,
                instanceId:that.$instanceid,
                boxId:that.$boxid,
                groupCode:that.$groupcode,
                category:that.$category
            }
            }).done(function(reslist){

            	var attachSum = reslist.attachmentList.length;
            	
            	
            	
                if(that.option.showUploadButton)   {
                	if(attachSum >0){

                        if(that.hasPreview){
                        	that.$table.html('<thead><tr><td class="text-right col-xs-1"><input type="checkbox" name="checkAll"></td><td class="text-left col-xs-6"><button type="button" class="btn btn-sm tool-btn download-zip" >批量下载</button>&nbsp;&nbsp;<button type="button" class="btn btn-sm tool-btn download-web" >下载至网盘</button></td><td class="text-right col-xs-4"><button type="button" class="btn btn-sm tool-btn upload-fn-btn" >上传文件</button></td></tr></thead><tbody></tbody>')
                        }else{
                        	that.$table.html('<thead><tr><td class="text-right col-xs-1"><input type="checkbox" name="checkAll"></td><td class="text-left col-xs-6"><button type="button" class="btn btn-sm tool-btn download-zip" >批量下载</button></td><td class="text-right col-xs-4"><button type="button" class="btn btn-sm tool-btn upload-fn-btn" >上传文件</button></td></tr></thead><tbody></tbody>')
                        }
                    	     
                	}else{
                		that.$table.html('<thead><tr><td class="text-right col-xs-1"><input type="checkbox" name="checkAll"></td><td class="text-right col-xs-11"><button type="button" class="btn btn-sm tool-btn upload-fn-btn" >上传文件</button></td></tr></thead><tbody></tbody>')
                	}
            	}else{
                	 if(attachSum >0){

                         if(that.hasPreview){
                        	 that.$table.html('<thead><tr><td class="text-right col-xs-1"><input type="checkbox" name="checkAll"></td><td colspan="2"  class="text-left col-xs-11"><button type="button" class="btn btn-sm tool-btn download-zip" >批量下载</button>&nbsp;&nbsp;<button type="button" class="btn btn-sm tool-btn download-web" >下载至网盘</button></td></tr></thead><tbody></tbody>')    
                         }else{
                        	 that.$table.html('<thead><tr><td class="text-right col-xs-1"><input type="checkbox" name="checkAll"></td><td colspan="2"  class="text-left col-xs-11"><button type="button" class="btn btn-sm tool-btn download-zip" >批量下载</button></td></tr></thead><tbody></tbody>')    
                         }
                	 }else{
                		 that.$table.html('')
                	 }
                 }
                 that.$table.find('tbody').first().html(that.getTableTrs(
                    {
                      'columns':[
                                 {'data':'id','myclass':'text-right col-xs-1','formatFunction':function(val,row){
                                        return '<input type="checkbox" name="check" id="'+val+'">';
                                 }},
                                 {'data':'fileName','myclass':'text-left col-xs-6','formatFunction':function(val,row){
                                	 	return '<label  title="'+val+'" for="'+row.id+'">'+val+'</label>';
                                 }},
                                 {'data':'id','myclass':'text-right col-xs-5 operate','formatFunction':function(val,row){
                                	 var oHtml = '';
                                    if(that.$category === row.category){
                                    	
                                    	oHtml = oHtml + '<div><a href="javascript:void(0);" data-id="'+val+'" class="moveup-a"><i class="fa fa-arrow-up icon-red"></i><font>上移</font></a>'
                                                    +'<a href="javascript:void(0);" data-id="'+val+'" class="movedown-a"><i class="fa fa-arrow-down icon-red"></i><font>下移</font></a>'
                                                    +'<a href="javascript:void(0);" data-id="'+val+'" class="delete-a"><i class="fa fa fa-trash-o icon-gray"></i><font>删除<font></a>'
                                                    +'<a href="javascript:void(0);" data-id="'+val+'" class="download-a"><i class="fa fa-download icon-green"></i><font>下载</font></a>';
	                                }else{
	                                	oHtml = oHtml + '<div><a href="javascript:void(0);" data-id="'+val+'" class="download-a"><i class="fa fa-download icon-green"></i><font>下载</font></a>';
	                                }
	                               	 if(row.canbePreview && that.hasPreview){
	                               		 oHtml = oHtml +'<a href="javascript:void(0);" data-id="'+val+'" class="preview-a"><i class="fa fa fa-eye icon-orange"></i><font>预览</font></a>';
	                               	 }
	                               	 oHtml = oHtml +'</div>';
                               	 return oHtml;
	                             }}]
                  },reslist.attachmentList));
                 
                 that.$table.data("attachSum",attachSum);
                 
                if(attachSum >0){
                	
                	that.bingCheck(that);
	                
                	that.bingDownloadZip(that);
                    
                    if(that.hasPreview){
                     	that.bingDownloadWeb(that, reslist.attachmentList);
                    }
                	
	                
                }
                
                if(that.option.showUploadButton)   {
                    that.$table.find('button.upload-fn-btn').click(function(){
                       that.openUploadDialog()
                    });
                 }
                that.bingDownloadA(that);
                
                that.bingMoveupA(that);
                
                that.bingMovedownA(that);
                
                that.bingDeleteA(that);
                
                if(that.hasPreview){
                	
                    that.bingPreview(that);
                }
                
                loadDtd.resolve(attachSum);
            }).fail(function(r){
                BootstrapUDialog.alert({ title: '提醒', message: '初始化附件列表数据失败', closable: true,  draggable: true });
                loadDtd.reject();
            });
            
            return loadDtd;
        }
        
        MbsUpload.prototype.loadOperateTable = function(){

            var loadDtd = $.Deferred();
            
            var that = this;
                     
            $.ajax({
            type : "get",
            url : that.selectPath,
            cache:false,
            dataType : "json",
            data :  {
                systemId:that.$systemid,
                modelId:that.$modelid,
                boDefinedId:that.$bodefinedid,
                instanceId:that.$instanceid,
                boxId:that.$boxid,
                groupCode:that.$groupcode
            }
            }).done(function(reslist){

            	var attachSum = reslist.attachmentList.length;
            	  if(that.option.showUploadButton)   {
                  	if(attachSum >0){

                          if(that.hasPreview){
                          	that.$table.html('<thead><tr><td class="text-right col-xs-1"><input type="checkbox" name="checkAll"></td><td class="text-left col-xs-6"><button type="button" class="btn btn-sm tool-btn download-zip" >批量下载</button>&nbsp;&nbsp;<button type="button" class="btn btn-sm tool-btn download-web" >下载至网盘</button></td><td class="text-right col-xs-4"><button type="button" class="btn btn-sm tool-btn upload-fn-btn" >上传文件</button></td></tr></thead><tbody></tbody>')
                          }else{
                          	that.$table.html('<thead><tr><td class="text-right col-xs-1"><input type="checkbox" name="checkAll"></td><td class="text-left col-xs-6"><button type="button" class="btn btn-sm tool-btn download-zip" >批量下载</button></td><td class="text-right col-xs-4"><button type="button" class="btn btn-sm tool-btn upload-fn-btn" >上传文件</button></td></tr></thead><tbody></tbody>')
                          }
                      	     
                  	}else{
                  		that.$table.html('<thead><tr><td class="text-right col-xs-1"><input type="checkbox" name="checkAll"></td><td class="text-right col-xs-11"><button type="button" class="btn btn-sm tool-btn upload-fn-btn" >上传文件</button></td></tr></thead><tbody></tbody>')
                  	}
              	}else{
                  	 if(attachSum >0){

                           if(that.hasPreview){
                          	 that.$table.html('<thead><tr><td class="text-right col-xs-1"><input type="checkbox" name="checkAll"></td><td colspan="2"  class="text-left col-xs-11"><button type="button" class="btn btn-sm tool-btn download-zip" >批量下载</button>&nbsp;&nbsp;<button type="button" class="btn btn-sm tool-btn download-web" >下载至网盘</button></td></tr></thead><tbody></tbody>')    
                           }else{
                          	 that.$table.html('<thead><tr><td class="text-right col-xs-1"><input type="checkbox" name="checkAll"></td><td colspan="2"  class="text-left col-xs-11"><button type="button" class="btn btn-sm tool-btn download-zip" >批量下载</button></td></tr></thead><tbody></tbody>')    
                           }
                  	 }else{
                  		 that.$table.html('')
                  	 }
                   }
            	  
                 that.$table.find('tbody').first().html(that.getTableTrs(
                    {
                      'columns':[
                                 {'data':'id','myclass':'text-right col-xs-1','formatFunction':function(val,row){
                                        return '<input type="checkbox" name="check" id="'+val+'">';
                                 }},
                                 {'data':'fileName','myclass':'text-left col-xs-6','formatFunction':function(val,row){
                                	 	return '<label  title="'+val+'" for="'+row.id+'">'+val+'</label>';
                                 }},
                                 {'data':'id','myclass':'text-right col-xs-5 operate','formatFunction':function(val,row){
                                	 
                                	 var oHtml = '<div><a href="javascript:void(0);" data-id="'+val+'" class="moveup-a"><i class="fa fa-arrow-up icon-red"></i><font>上移</font></a>'
                                     +'<a href="javascript:void(0);" data-id="'+val+'" class="movedown-a"><i class="fa fa-arrow-down icon-red"></i><font>下移</font></a>'
                                     +'<a href="javascript:void(0);" data-id="'+val+'" class="delete-a"><i class="fa fa fa-trash-o icon-gray"></i><font>删除<font></a>'
                                     +'<a href="javascript:void(0);" data-id="'+val+'" class="download-a"><i class="fa fa-download icon-green"></i><font>下载</font></a>';
                                	 if(row.canbePreview && that.hasPreview){
	                               		 oHtml = oHtml +'<a href="javascript:void(0);" data-id="'+val+'" class="preview-a"><i class="fa fa fa-eye icon-orange"></i><font>预览</font></a>';
	                               	 }
	                               	 oHtml = oHtml +'</div>';
	                               	 return oHtml;
                                 }}]
                  },reslist.attachmentList));
                 
                 that.$table.data("attachSum",attachSum);
                 
                 if(attachSum >0){
                 	
                 	that.bingCheck(that);
 	                
                 	that.bingDownloadZip(that);
                	
                 	 if(that.hasPreview){
                      	that.bingDownloadWeb(that, reslist.attachmentList);
                     }
                 	
 	                
                 }
                 
                 if(that.option.showUploadButton)   {
                     that.$table.find('button.upload-fn-btn').click(function(){
                        that.openUploadDialog()
                     });
                  }
                 that.bingDownloadA(that);
                 
                 that.bingMoveupA(that);
                 
                 that.bingMovedownA(that);
                 
                 that.bingDeleteA(that);
                 
                 if(that.hasPreview){
                     that.bingPreview(that);
                 }
             	
                 
                 loadDtd.resolve(attachSum);
               
            }).fail(function(r){
                BootstrapUDialog.alert({ title: '提醒', message: '初始化附件列表数据失败', closable: true,  draggable: true });
                loadDtd.reject();
            });
            return loadDtd;
        }

        MbsUpload.prototype.hasPreviewAuth = function(that){
        	var that = this;
            var dtd = $.Deferred();
            $.ajax({
            type : "get",
            url : that.queryAuth,
            dataType : "json",
            data : {}
            }).done(function(res){
                dtd.resolve(res.hasPreview);
            }).fail(function(res){
                dtd.reject(res.hasPreview);
            });
            return dtd.promise(); 
        }
        
        MbsUpload.prototype.bingCheck = function(that){
        	that.$table.find('input[name="checkAll"]').first().click(function(){
                var _check = this.checked;
                that.$table.find('input[name="check"]').each(function(){
                    this.checked = _check;
                });
            });
        }
        
        MbsUpload.prototype.bingDownloadZip = function(that){
        	that.$table.find('button.download-zip').click(function(){
                var checkedIdArray = that.getTableChecked();
                if(checkedIdArray.length<1){
                	BootstrapUDialog.alert({ title: '提醒', message: '请选择要下载的附件', closable: true,  draggable: true });
                	return;
                }
                var ids=new Array();
                for(var i=0;i<checkedIdArray.length;i++){
                	ids.push(checkedIdArray[i]);
                }

                that.downloadAttach(ids);
            });
        }
        MbsUpload.prototype.bingDownloadA = function(that){
        	 that.$table.find('a.download-a').click(function(){
                 var _this = $(this);
                 var _id = _this.data('id');
                 var ids = new Array();
                 	ids.push(_id);
                 that.downloadAttach(ids);
             });
        }
        MbsUpload.prototype.bingMoveupA = function(that){
        	that.$table.find('a.moveup-a').click(function(){
                var _this = $(this);
                var _id = _this.data('id');
                $.ajax({
                type : "post",
                url : that.moveupPath,
                dataType : "json",
                data : {
                	systemId:that.$systemid,
                	attachmentId:_id
                }
                }).done(function(res){
                    that.loadTable(that);
                }).always(function(){
                });
            });
        }
        MbsUpload.prototype.bingMovedownA = function(that){
        	that.$table.find('a.movedown-a').click(function(){
                var _this = $(this);
                var _id = _this.data('id');
                $.ajax({
                type : "post",
                url : that.movedownPath,
                dataType : "json",
                data : {
                	systemId:that.$systemid,
                	attachmentId:_id
                }
                }).done(function(res){
                    that.loadTable(that);
                }).always(function(){
                });
                
            });
        }
        MbsUpload.prototype.bingDeleteA = function(that){
        	that.$table.find('a.delete-a').click(function(){
                var _this = $(this);
                var _id = _this.data('id');
                BootstrapUDialog.confirm('删除后附件不可恢复,确定删除?', function(result){
                    if(result) {
                    	 that.deleteById(_id).done(function(){  
                             that.loadTable(that);
                         }).fail(function(){
                             BootstrapUDialog.alert({ title: '提醒', message: '删除失败！', closable: true,  draggable: true });
                         });
                    }
                });
                
            });
        }
        MbsUpload.prototype.bingPreview = function(that){
            that.$table.find('a.preview-a').click(function(){
                var _this = $(this);
                var _id = _this.data('id');
                that.previewAttach(_id);
            });
        }
       
        MbsUpload.prototype.downloadAttach = function(ids){
        	var url = this.downloadPath+"?attachmentId="+ids+"&systemId="+this.$systemid;
        	var downloadIframe = document.getElementById('downLoadIframe');
        	if(downloadIframe){
        		downloadIframe.src = url;
        	}else{
        		downloadIframe = document.createElement('iframe');
        		downloadIframe.id = 'downLoadIframe';
        		downloadIframe.src = url;
        		downloadIframe.style.display = "none";
        		document.body.appendChild(downloadIframe);
        	}
        }

        MbsUpload.prototype.previewAttach = function(_id){
        	var that = this;
        	$.ajax({
        		url: that.previewPath,
        		type: 'get',
        		dataType: 'json',
        		data: {attachmentId: _id,systemId:that.$systemid}
        	})
        	.done(function(r) {
        		that.openPreviewDialog(r.previewPath, r.previewTempName, r.primaryName);
        	})
        	.fail(function() {
        		BootstrapUDialog.alert( '生成预览文件失败！');
        	});

        	/*this.uploadWindow = window.open(this.previewPath+"?attachmentId="+_id+"&systemId="+this.$systemid);*/
        	
        }
        MbsUpload.prototype.getTableTrs = function(setting,array){
            var trs = '';
              $.each(array,function(index,result){
                  trs += '<tr>'; 
                    $.each(setting.columns,function(index,tdSet){
                         if($.isFunction(tdSet.formatFunction)){
                            trs +='<td  class="'+tdSet.myclass+'">'+tdSet.formatFunction(result[tdSet.data],result)+'</td>';
                          }else{
                            trs +='<td class="'+tdSet.myclass+'">'+result[tdSet.data]+'</td>';
                          }
                        });
                    trs +='</tr>';
                });
              return trs;

        }
        MbsUpload.prototype.getTableChecked = function(){
            var idArray = new Array();
            this.$table.find('input[name="check"]').each(
                function(){
                    if(this.checked){
                        idArray.push(this.id);
                    }
                });
            return idArray;
        }
        
        MbsUpload.prototype.deleteById = function(_id){
            var that = this;
            var dtd = $.Deferred();
            $.ajax({
            type : "post",
            url : that.deletePath,
            dataType : "json",
            data : {
            	attachmentId:_id,
            	systemId:that.$systemid
            }
            }).done(function(res){
                dtd.resolve();
            }).fail(function(res){
                dtd.reject();
            });
            return dtd.promise(); 
        }
        MbsUpload.prototype.getCurrentUser = function(){
        	var that = this;
            var dtd = $.Deferred();
            $.ajax({
                type : "get",
                url : that.getUserId,
                cache:false,
                dataType : "json",
                data :  {}
                }).done(function(res){
                    dtd.resolve(res);
                }).fail(function(res){
                    dtd.reject();
                });
            return dtd.promise(); 
        }
        MbsUpload.prototype.uploadByStoreAdress = function(_srcSystemId,_srcStoreAddress,_destfilename){
        	var that = this;
            var dtd = $.Deferred();
            $.ajax({
                type : "post",
                url : that.uploadByStoreAddress,
                cache:false,
                dataType : "json",
                data :  {srcSystemId:_srcSystemId,srcStoreAddress:_srcStoreAddress,destSystemId:that.$systemid,destfilename:_destfilename,
                        systemId:that.$systemid,
                        modelId:that.$modelid,
                        boDefinedId:that.$bodefinedid,
                        instanceId:that.$instanceid,
                        boxId:that.$boxid,
                        groupCode:that.$groupcode,
                        category:that.$category
                		}
                }).done(function(res){
                    dtd.resolve(res);
                }).fail(function(res){
                    dtd.reject();
                });
            return dtd.promise(); 
        }
        
        
        MbsUpload.prototype.uploadWeb = function(_divId,_srcSystemId,_srcStoreAddress,_destfilename){
        	var that = this;
            	var $this = $('#'+_divId);
            	var $li = $this, $percent = $li.find('.progress .progress-bar');

                if (!$percent.length) {
                    $percent = $('<div class="progress progress-striped active"><div class="progress-bar" role="progressbar" style="width: 0%"></div></div>').appendTo($li).find('.progress-bar');
                }

                $li.find('p.state').text('上传中');

                $percent.animate({width:"48%"}).animate({width:"68%"}).animate({width:"88%"}).animate({width:"98%"}); 
                that.uploadByStoreAdress(_srcSystemId,_srcStoreAddress,_destfilename).done(function(res){
                    	 var $deleteI = $li.find('.deleteI'), $progress = $li.find('.progress');
                         $deleteI.data('id',res.attachment.id);
                         
                         $percent.stop(true, true).animate({width:"100%"},
             					"fast",'linear',function(){
                             $li.find('p.state').text('上传成功');
                             $progress.remove();
             			}); 
                     }).fail(function(res){ 
                    	 var $progress = $li.find('.progress');
                    	 
                         $percent.stop(true, true).animate({width:"100%"},
              					"fast",'linear',function(){
                        	 $li.find('p.state').text('上传失败');
                             $progress.remove();
              			}); 
                     });
        };
        MbsUpload.prototype.bingDownloadWeb = function(that, attachmentList){
        	that.$table.find('button.download-web').click(function(){
                var checkedIdArray = that.getTableChecked();
                if(checkedIdArray.length<1){
                	BootstrapUDialog.alert({ title: '提醒', message: '请选择要下载的附件', closable: true,  draggable: true });
                	return;
                }
                var fileArray = new Array();
                for(var i=0;i<checkedIdArray.length;i++){
                	fileArray.push({
                		id:that.nameCache[checkedIdArray[i]].address,
                		name:that.nameCache[checkedIdArray[i]].fileName,
                		systemId:that.$systemid,
                		model_id:that.$modelid,
                		bo_def_id:that.$bodefinedid,
                		bo_instance_id:that.$instanceid
                	});
                }
                that.getCurrentUser().done(function(res){
                    fileweb.downloadToWeb(res.uid,fileArray);
                }).fail(function(res){
                    	BootstrapUDialog.alert({ title: '提醒', message: '获取用户失败！', closable: true,  draggable: true });
                });
                
            });
        	

        	$.each(attachmentList,function(i,val){
            	that.nameCache[val.id] = {fileName:val.fileName,address:val.storeAddress};
            });
        }
        MbsUpload.prototype.openPreviewDialog = function(tempFilePath,_fileName,primaryName){
        	this.previewId = 'dv' + BootstrapUDialog.newGuid();
        	this.$previewDiv = $('<div id="'+this.previewId+'" class="flexpaper_viewer" style="width:100%;"></div>');
        	 var that = this;
        	BootstrapUDialog.show({
                 title: primaryName,
                 message: that.$previewDiv,
                 size: BootstrapUDialog.SIZE_WIDE,
                 closable: true,
                 closeByBackdrop: false,
                 onshown:function(){ 
                	 tempFilePath = that.option.basePath +"/"+ tempFilePath;
                	 var swfStr = ".swf";
                	 if(_fileName.match(swfStr+"$") == swfStr){
                    	 that.initSwf(that.previewId, that.option.basePath + '/static/ui-frame/flexpaper/js/', tempFilePath);
                	 }else{
                		 that.initImg(that.previewId, tempFilePath);
                	 }
                 },
                 onhidden : function(){
                	 $.ajax({
                         type : "post",
                         url : that.previewDeletePath,
                         dataType : "json",
                         data : {
                        	 fileName:_fileName
                         }
                         }).done(function(){});
                	 
                 }
             });
        }
        MbsUpload.prototype.initSwf = function(previewDivId, baseJsPath, swfPath){
        	$('#'+ previewDivId).css("height","480px").FlexPaperViewer(
 	                { config : {
 	                	jsDirectory : baseJsPath,
 	                    SWFFile : swfPath,
 	                    Scale : 1,
 	                    ZoomTransition : 'none',
 	                    ZoomTime : 0,
 	                    ZoomInterval : 0,
 	                    FitPageOnLoad : false,
 	                    FitWidthOnLoad : true,
 	                    FullScreenAsMaxWindow : false,
 	                    ProgressiveLoading : true,
 	                    MinZoomSize : 0.2,
 	                    MaxZoomSize : 5,
 	                    SearchMatchAll : false,
 	                    InitViewMode : 'Portrait',
 	                    RenderingOrder : 'flash',
 	                    StartAtPage : '',
 	                    ViewModeToolsVisible : true,
 	                    ZoomToolsVisible : true,
 	                    NavToolsVisible : true,
 	                    CursorToolsVisible : true,
 	                    SearchToolsVisible : false,
 	                    WMode : 'window',
 	                    localeChain: 'zh_CN'
 	                }}
 	        );
        }
        MbsUpload.prototype.initImg = function(previewDivId, imgPath){
        	var _parentDiv = $('#' + previewDivId);
        	_parentDiv.html('<img src="'+imgPath+'" alt="未请求到预览文件" style="width:100%;"/>');
        	
        }
        MbsUpload.prototype.openUploadDialog = function(){
        	this.uploaderId = BootstrapUDialog.newGuid();
        	this.filePickerId = BootstrapUDialog.newGuid();
        	
        	
        	var divHtml = '<div id="'+ this.uploaderId +'">';
        	

    		if(this.hasPreview){
    			divHtml = divHtml + '<div class="btn web-btn" style="float:right;">从网盘上传</div>';
    		}
    		divHtml = divHtml + '<div id="f'+this.filePickerId+'" class="filePicker" style="float:right;">选择文件</div><div style="clear:both;"></div>';
        	 if (window.applicationCache) {
        		 divHtml = divHtml + '<div class="fileList"><p class="note">请点击选择文件或拖动文件到这里:单个文件不能大于30M</p></div></div>';
             } else {
            	 divHtml = divHtml + '<div class="fileList"><p class="note">请点击选择文件:单个文件不能大于30M</p></div></div>';
             } 
        	 this.$dialog = $(divHtml);
            var that = this;
              BootstrapUDialog.show({
                title: that.$title,
                message: that.$dialog,
                cssClass: that.DIALOG_CLASS,
                closable: false,
                onshown:function(){
                    var $list = that.$dialog.find('.fileList').first();

                    var $webbtn = that.$dialog.find('.web-btn').first();
                    
                    var setting = {
                            pick : '#f'+that.filePickerId,
                            formData:{
                                systemId:that.$systemid,
                                modelId:that.$modelid,
                                boDefinedId:that.$bodefinedid,
                                instanceId:that.$instanceid,
                                boxId:that.$boxid,
                                groupCode:that.$groupcode,
                                category:that.$category
                            },
                            swf : that.swfPath,
                            
                            server : that.uploadPath,
                            fileSingleSizeLimit: 30*1024*1024 //30M 
                        };

                    if ( !WebUploader.Uploader.support() ) {
                    	BootstrapUDialog.alert( '文件上传不支持您的浏览器！如果你使用的是IE浏览器，请尝试升级 flash 播放器');
                        throw new Error( 'WebUploader does not support the browser you are using.' );
                    }
                    if (window.applicationCache) {
                    	setting = $.extend({ dnd: '#' + that.uploaderId + ' .fileList',paste: document.body,disableGlobalDnd: true},setting)
                    }
                    that.uploadInstance = WebUploader.create(setting);
                    that.uploadInstance.on( 'beforeFileQueued', function( file ) {
                    	if(file.name.length > 50){
                            this.trigger( 'error', 'FILE_NAME_SIZE_OVER', 50, file );
                            return false;
                    	}else{
                    		return true;
                    	}
                    });
                    
                    that.uploadInstance.on('fileQueued', function(file) {
                    	var $txt = $('#' + that.uploaderId + ' .fileList p');
                    	if('block' == $txt.css('display')){
                    		$txt.hide();
                    	}
                        var $div = $('<div id="' + file.id + '" class="item"><h4 class="info">' + file.name + '&nbsp;<i class="fa fa-times deleteI" data-id=""></i></h4><p class="state">等待上传...</p>' + '</div>');
                        $list.append($div);


                        var $deleteI = $div.find('.deleteI').first();
                        $deleteI.click(function(){
                            var $ele = $(this);
                            var id = $ele.parent().parent().attr("id");
                            that.uploadInstance.removeFile( id, true );
                            var fileId = $ele.data('id');
                            if(null !=  fileId && '' !=  fileId){
                                that.deleteById(fileId).done(function(){  
                                    $ele.parent().parent().remove();
                                }).fail(function(){
                                    BootstrapUDialog.alert({ title: '提醒', message: '删除失败！', closable: true,  draggable: true });
                                });
                            }else{
                                $ele.parent().parent().remove();
                            }
                        });
                    });
                    that.uploadInstance.on('fileQueued', function (file) {
                        that.uploadInstance.upload();
                    });
                    

                    that.uploadInstance.on('error',function(type,max,file){
                    	if('F_EXCEED_SIZE' == type){
                    		BootstrapUDialog.alert({ title: '提醒', message: file.name+'大于30M,请选择小于30M的文件！', closable: true,  draggable: true });
                    	}else if('FILE_NAME_SIZE_OVER' == type){
                    		BootstrapUDialog.alert({ title: '提醒', message: file.name+'上传的文件名最长'+max+'个字符！', closable: true,  draggable: true });
                    	}
                    });


                    that.uploadInstance
                            .on(
                                    'uploadProgress',
                                    function(file, percentage) {
                                        var $li = $('#' + file.id), $percent = $li.find('.progress .progress-bar');

                                        if (!$percent.length) {
                                            $percent = $('<div class="progress progress-striped active"><div class="progress-bar" role="progressbar" style="width: 0%"></div></div>').appendTo($li).find('.progress-bar');
                                        }

                                        $li.find('p.state').text('上传中');

                                        $percent.css('width', percentage * 100 + '%');
                                    });     

                    that.uploadInstance.on('uploadSuccess', function(file,res) {
                            var $li = $('#' + file.id), $deleteI = $li.find('.deleteI'), $progress = $li.find('.progress');
                            $deleteI.data('id',res.attachmentList[0].id);
                            $('#' + file.id).find('p.state').text('上传成功');
                            $progress.remove();
                    });

                    that.uploadInstance.on('uploadError', function(file) {
                        var $li = $('#' + file.id), $progress = $li.find('.progress');
                        $('#' + file.id).find('p.state').text('上传失败');
                        $progress.remove();
                    });


                    that.uploadInstance.on('all', function(type) {
                        switch( type ) {
                            case 'uploadFinished':
                                that.uploadStatus = 'done';
                                break;

                            case 'startUpload':
                                that.uploadStatus = 'uploading';
                                break;

                            case 'stopUpload':
                                that.uploadStatus = 'paused';
                                break;

                        }
                    });
                    
                    
                    if(that.hasPreview){
                    	
	                    $webbtn.click(function(){
	                    	that.getCurrentUser().done(function(res){
		                    	fileweb.uploadFromWeb(res.uid,function(fileArray){
		                    		$.each(fileArray,function(index, val){
		                    			var webDiv = $('#' + val.fileId);
		                            	if(webDiv.length < 1){
		                                	var $div = $('<div id="' + val.fileId + '" class="ref"><h4 class="info">' + val.fileName + ' &nbsp;<i class="fa fa-times deleteRef" ></i></h4><p class="state">等待上传...</p>' + '</div>');
		                                	var $txt = $('#' + that.uploaderId + ' .fileList p');
		                                	if('block' == $txt.css('display')){
		                                		$txt.hide();
		                                	}
		                                	$list.append($div);
		                                    $div.data("systemId",val.systemId);
		                                    $div.data("addressId",val.fileId);
		                                    $div.data("filename",val.fileName);
		                                    
		                                    var $deleteRef = $div.find('.deleteRef');
		                                    $deleteRef.click(function(){
		                                    	var $ele = $(this);
		                                        var id = $ele.parent().parent().attr("id");
		                                        var fileId = $ele.data('id');
		                                        if(null !=  fileId && '' !=  fileId){
		                                            that.deleteById(fileId).done(function(){  
		                                                $ele.parent().parent().remove();
		                                            }).fail(function(){
		                                                BootstrapUDialog.alert({ title: '提醒', message: '删除失败！', closable: true,  draggable: true });
		                                            });
		                                        }else{
		                                            $ele.parent().parent().remove();
		                                        }
		                                    });
		                                    that.uploadWeb( val.fileId,val.systemId,val.fileId,val.fileName);
		                                    
		                            	}
		                    		});
		                    	});
	                    	}).fail(function(){
	                        	BootstrapUDialog.alert({ title: '提醒', message: '获取用户失败！', closable: true,  draggable: true });
	                    	});
	                    	
	                    });
                    }
                },
                buttons: [ {
                    label: '确定',
                    action: function(dialogRef){
                        if(null != that.uploadStatus && 'done' == that.uploadStatus){
                        	if(null != that.$category && '' != that.$category){
                        		that.loadOTWidthCategory().done(function(attachSum){
                                    that.$table.trigger("attachLoaded",attachSum);
                        		});
                        	}else{
                        		that.loadOperateTable().done(function(attachSum){
                                    that.$table.trigger("attachLoaded",attachSum);
                        		});
                        	}
                            if(null != that.uploadInstance){
                                that.uploadInstance.destroy();
                            }
                            dialogRef.close();
                        }else{
                            BootstrapUDialog.alert({ title: '提醒', message: "请等待上传完毕", closable: true,  draggable: true });
                        }
                    }},{
                    label: '取消',
                    action: function(dialogRef){
                        if(null != that.uploadInstance){
                        	that.$dialog.find('.deleteI').each(function(){
                        		$(this).click();
                        	});
                            that.uploadInstance.destroy();
                        }
                        dialogRef.close();
                    }
                }]
            });
              
              

        
        
	   }

	


	//当前工程basepath
	MbsUpload.basePath = attachBasePath;

	MbsUpload.VERSION  = '1.0.0';





	function Plugin(option) {
		return this.each(function() {
			var $this = $(this);
			var data = $this.data('upload.uploaddata');
			if (!data) {
				var eOption = $this.data()

				var options = $.extend({}, {'basePath':MbsUpload.basePath},eOption, typeof option == 'object' && option);
				$this.data('upload.uploaddata', (data = new MbsUpload(this,options)));
			}
		})
	}

	var old = $.fn.MbsUpload;

	$.fn.MbsUpload             = Plugin;
	$.fn.MbsUpload.Constructor = MbsUpload;
	
	//MbsUpload NO CONFLICT
	//=================

	$.fn.MbsUpload.noConflict = function () {
	$.fn.MbsUpload = old;
	return this;
	};
	$(document).ready(function() {
		Plugin.call($('.upload-element'));
		$.fn.upload = function() {
			var uploadInstance = $(this).data('upload.uploaddata');
			if(uploadInstance){
				uploadInstance.openUploadDialog()
			}else{
				throw new Error('请指定正确的目标table');
			}
		}
	});

	

});


/*! Sea.js 2.2.1 | seajs.org/LICENSE.md */
!function(a,b){function c(a){return function(b){return{}.toString.call(b)=="[object "+a+"]"}}function d(){return A++}function e(a){return a.match(D)[0]}function f(a){for(a=a.replace(E,"/");a.match(F);)a=a.replace(F,"/");return a=a.replace(G,"$1/")}function g(a){var b=a.length-1,c=a.charAt(b);return"#"===c?a.substring(0,b):".js"===a.substring(b-2)||a.indexOf("?")>0||".css"===a.substring(b-3)||"/"===c?a:a+".js"}function h(a){var b=v.alias;return b&&x(b[a])?b[a]:a}function i(a){var b=v.paths,c;return b&&(c=a.match(H))&&x(b[c[1]])&&(a=b[c[1]]+c[2]),a}function j(a){var b=v.vars;return b&&a.indexOf("{")>-1&&(a=a.replace(I,function(a,c){return x(b[c])?b[c]:a})),a}function k(a){var b=v.map,c=a;if(b)for(var d=0,e=b.length;e>d;d++){var f=b[d];if(c=z(f)?f(a)||a:a.replace(f[0],f[1]),c!==a)break}return c}function l(a,b){var c,d=a.charAt(0);if(J.test(a))c=a;else if("."===d)c=f((b?e(b):v.cwd)+a);else if("/"===d){var g=v.cwd.match(K);c=g?g[0]+a.substring(1):a}else c=v.base+a;return 0===c.indexOf("//")&&(c=location.protocol+c),c}function m(a,b){if(!a)return"";a=h(a),a=i(a),a=j(a),a=g(a);var c=l(a,b);return c=k(c)}function n(a){return a.hasAttribute?a.src:a.getAttribute("src",4)}function o(a,b,c){var d=S.test(a),e=L.createElement(d?"link":"script");if(c){var f=z(c)?c(a):c;f&&(e.charset=f)}p(e,b,d,a),d?(e.rel="stylesheet",e.href=a):(e.async=!0,e.src=a),T=e,R?Q.insertBefore(e,R):Q.appendChild(e),T=null}function p(a,c,d,e){function f(){a.onload=a.onerror=a.onreadystatechange=null,d||v.debug||Q.removeChild(a),a=null,c()}var g="onload"in a;return!d||!V&&g?(g?(a.onload=f,a.onerror=function(){C("error",{uri:e,node:a}),f()}):a.onreadystatechange=function(){/loaded|complete/.test(a.readyState)&&f()},b):(setTimeout(function(){q(a,c)},1),b)}function q(a,b){var c=a.sheet,d;if(V)c&&(d=!0);else if(c)try{c.cssRules&&(d=!0)}catch(e){"NS_ERROR_DOM_SECURITY_ERR"===e.name&&(d=!0)}setTimeout(function(){d?b():q(a,b)},20)}function r(){if(T)return T;if(U&&"interactive"===U.readyState)return U;for(var a=Q.getElementsByTagName("script"),b=a.length-1;b>=0;b--){var c=a[b];if("interactive"===c.readyState)return U=c}}function s(a){var b=[];return a.replace(X,"").replace(W,function(a,c,d){d&&b.push(d)}),b}function t(a,b){this.uri=a,this.dependencies=b||[],this.exports=null,this.status=0,this._waitings={},this._remain=0}if(!a.seajs){var u=a.seajs={version:"2.2.1"},v=u.data={},w=c("Object"),x=c("String"),y=Array.isArray||c("Array"),z=c("Function"),A=0,B=v.events={};u.on=function(a,b){var c=B[a]||(B[a]=[]);return c.push(b),u},u.off=function(a,b){if(!a&&!b)return B=v.events={},u;var c=B[a];if(c)if(b)for(var d=c.length-1;d>=0;d--)c[d]===b&&c.splice(d,1);else delete B[a];return u};var C=u.emit=function(a){var b=B[a],c;if(b){b=b.slice();for(var d=Array.prototype.slice.call(arguments,1);c=b.shift();)c.apply(null,d)}return u},D=/[^?#]*\//,E=/\/\.\//g,F=/\/[^/]+\/\.\.\//,G=/([^:/])\/\//g,H=/^([^/:]+)(\/.+)$/,I=/{([^{]+)}/g,J=/^\/\/.|:\//,K=/^.*?\/\/.*?\//,L=document,M=e(L.URL),N=L.scripts,O=L.getElementById("seajsnode")||N[N.length-1],P=e(n(O)||M);u.resolve=m;var Q=L.head||L.getElementsByTagName("head")[0]||L.documentElement,R=Q.getElementsByTagName("base")[0],S=/\.css(?:\?|$)/i,T,U,V=+navigator.userAgent.replace(/.*(?:AppleWebKit|AndroidWebKit)\/(\d+).*/,"$1")<536;u.request=o;var W=/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|\/\*[\S\s]*?\*\/|\/(?:\\\/|[^\/\r\n])+\/(?=[^\/])|\/\/.*|\.\s*require|(?:^|[^$])\brequire\s*\(\s*(["'])(.+?)\1\s*\)/g,X=/\\\\/g,Y=u.cache={},Z,$={},_={},ab={},bb=t.STATUS={FETCHING:1,SAVED:2,LOADING:3,LOADED:4,EXECUTING:5,EXECUTED:6};t.prototype.resolve=function(){for(var a=this,b=a.dependencies,c=[],d=0,e=b.length;e>d;d++)c[d]=t.resolve(b[d],a.uri);return c},t.prototype.load=function(){var a=this;if(!(a.status>=bb.LOADING)){a.status=bb.LOADING;var c=a.resolve();C("load",c,a);for(var d=a._remain=c.length,e,f=0;d>f;f++)e=t.get(c[f]),e.status<bb.LOADED?e._waitings[a.uri]=(e._waitings[a.uri]||0)+1:a._remain--;if(0===a._remain)return a.onload(),b;var g={};for(f=0;d>f;f++)e=Y[c[f]],e.status<bb.FETCHING?e.fetch(g):e.status===bb.SAVED&&e.load();for(var h in g)g.hasOwnProperty(h)&&g[h]()}},t.prototype.onload=function(){var a=this;a.status=bb.LOADED,a.callback&&a.callback();var b=a._waitings,c,d;for(c in b)b.hasOwnProperty(c)&&(d=Y[c],d._remain-=b[c],0===d._remain&&d.onload());delete a._waitings,delete a._remain},t.prototype.fetch=function(a){function c(){u.request(g.requestUri,g.onRequest,g.charset)}function d(){delete $[h],_[h]=!0,Z&&(t.save(f,Z),Z=null);var a,b=ab[h];for(delete ab[h];a=b.shift();)a.load()}var e=this,f=e.uri;e.status=bb.FETCHING;var g={uri:f};C("fetch",g);var h=g.requestUri||f;return!h||_[h]?(e.load(),b):$[h]?(ab[h].push(e),b):($[h]=!0,ab[h]=[e],C("request",g={uri:f,requestUri:h,onRequest:d,charset:v.charset}),g.requested||(a?a[g.requestUri]=c:c()),b)},t.prototype.exec=function(){function a(b){return t.get(a.resolve(b)).exec()}var c=this;if(c.status>=bb.EXECUTING)return c.exports;c.status=bb.EXECUTING;var e=c.uri;a.resolve=function(a){return t.resolve(a,e)},a.async=function(b,c){return t.use(b,c,e+"_async_"+d()),a};var f=c.factory,g=z(f)?f(a,c.exports={},c):f;return g===b&&(g=c.exports),delete c.factory,c.exports=g,c.status=bb.EXECUTED,C("exec",c),g},t.resolve=function(a,b){var c={id:a,refUri:b};return C("resolve",c),c.uri||u.resolve(c.id,b)},t.define=function(a,c,d){var e=arguments.length;1===e?(d=a,a=b):2===e&&(d=c,y(a)?(c=a,a=b):c=b),!y(c)&&z(d)&&(c=s(""+d));var f={id:a,uri:t.resolve(a),deps:c,factory:d};if(!f.uri&&L.attachEvent){var g=r();g&&(f.uri=g.src)}C("define",f),f.uri?t.save(f.uri,f):Z=f},t.save=function(a,b){var c=t.get(a);c.status<bb.SAVED&&(c.id=b.id||a,c.dependencies=b.deps||[],c.factory=b.factory,c.status=bb.SAVED)},t.get=function(a,b){return Y[a]||(Y[a]=new t(a,b))},t.use=function(b,c,d){var e=t.get(d,y(b)?b:[b]);e.callback=function(){for(var b=[],d=e.resolve(),f=0,g=d.length;g>f;f++)b[f]=Y[d[f]].exec();c&&c.apply(a,b),delete e.callback},e.load()},t.preload=function(a){var b=v.preload,c=b.length;c?t.use(b,function(){b.splice(0,c),t.preload(a)},v.cwd+"_preload_"+d()):a()},u.use=function(a,b){return t.preload(function(){t.use(a,b,v.cwd+"_use_"+d())}),u},t.define.cmd={},a.define=t.define,u.Module=t,v.fetchedList=_,v.cid=d,u.require=function(a){var b=t.get(t.resolve(a));return b.status<bb.EXECUTING&&(b.onload(),b.exec()),b.exports};var cb=/^(.+?\/)(\?\?)?(seajs\/)+/;v.base=(P.match(cb)||["",P])[1],v.dir=P,v.cwd=M,v.charset="utf-8",v.preload=function(){var a=[],b=location.search.replace(/(seajs-\w+)(&|$)/g,"$1=1$2");return b+=" "+L.cookie,b.replace(/(seajs-\w+)=1/g,function(b,c){a.push(c)}),a}(),u.config=function(a){for(var b in a){var c=a[b],d=v[b];if(d&&w(d))for(var e in c)d[e]=c[e];else y(d)?c=d.concat(c):"base"===b&&("/"!==c.slice(-1)&&(c+="/"),c=l(c)),v[b]=c}return C("config",a),u}}}(this);
// Set configuration
seajs.config({
  base: attachBasePath + "/static/ui-frame/"
});

/*! WebUploader 0.1.5 */
seajs.use("webuploader/0.1.5/webuploader.min");
/*modal BootstrapUDialog*/
seajs.use("bootstrap-m-dialog3/js/bootstrap-m-dialog.min");
/*flexpaper*/
seajs.use("flexpaper/js/flexpaper");
/*folder-网盘依赖*/
seajs.use("webuploader/0.1.5/folder");
/*fileweb-网盘方法*/
seajs.use("webuploader/0.1.5/fileweb");
/*ztree-v3-网盘依赖*/
if(!$.fn.zTree){
	seajs.use("ztree-v3/js/jquery.ztree.all-3.5.min");
}

